﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;

namespace AWZhome.NQ.CommonServices.Visual
{
	/// <summary>
	/// Interaction logic for UpdateSelectViewVisual.xaml
	/// </summary>
	public partial class UpdateSelectViewVisual : UserControl
	{
		public UpdateSelectViewVisual()
		{
			InitializeComponent();
		}

		private void InstallButton_Click(object sender, RoutedEventArgs e)
		{
			ReleaseListEntry relEntry = ((FrameworkElement) sender).DataContext as ReleaseListEntry;
			if (relEntry != null)
			{
				if (!relEntry.IsSelectedForInstall)
				{
					((UpdateSelectView) this.DataContext).MarkComponentForInstall(relEntry);
				}
				else
				{
					((UpdateSelectView) this.DataContext).MarkComponentForUninstall(relEntry);
				}

				// Update IsChecked property
				((ToggleButton) sender).GetBindingExpression(ToggleButton.IsCheckedProperty).UpdateTarget();
			}
		}
	}
}
